Skip to content

fix: preserve multi-element script[] arrays in sync roundtrip - #120

Merged
padak merged 1 commit into
mainfrom
fix/119-script-array-collapse
Apr 11, 2026
Merged

fix: preserve multi-element script[] arrays in sync roundtrip#120
padak merged 1 commit into
mainfrom
fix/119-script-array-collapse

Conversation

@padak

@padak padak commented Apr 11, 2026

Copy link
Copy Markdown
Member

Summary

  • sync pull + sync push was collapsing parameters.blocks[].codes[].script[] from N elements to 1, causing Snowflake runtime errors (MULTI_STATEMENT_COUNT=1)
  • Implemented a state-machine SQL splitter that splits on semicolons while respecting strings, comments, and dollar-quoted blocks
  • Matches the approach used by the old keboola-as-code CLI and the Keboola UI
  • SQL file stays clean -- no artificial markers injected into user code

Test plan

  • Unit tests: 25 new tests for SQL splitter (ported from old CLI's Go test suite)
  • Unit tests: 2 new multi-element roundtrip tests in code extraction suite
  • Verified on real production transformation (Slevomat Main Task: 374 script elements, 30 code blocks, 518KB SQL) -- content-identical after roundtrip
  • Backwards compatible: single-element scripts behave identically to before
  • Full suite: 1405 passed, 0 failed

Closes #119

sync pull/push was collapsing transformation script[] arrays from N
elements to 1, causing Snowflake runtime errors (MULTI_STATEMENT_COUNT=1).

Root cause: extraction joined all script elements without boundaries,
and merge always returned a single-element array.

Fix: use a state-machine SQL splitter (split on semicolons respecting
strings, comments, dollar-quotes) matching the approach of the old
keboola-as-code CLI and the Keboola UI. The SQL file stays clean with
no artificial markers.

Closes #119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync push collapses transformation script[] array → runtime fails

1 participant